package org.java.inner;

/**
 * 使用内部类的典型做法应该是：
 * 外部类会有一个方法，返回一个指向内部类的引用
 * @author imaginedays
 *
 */
public class InnerClass {
	
	class Contents{
		private int i = 11;
		public int value(){ return i;};
	}
	
	class Destination{
		private String label;
		Destination(String whereTo){
			label = whereTo;
		}
		String readLabel(){ return label;}
		
	}
	
	public Destination to(String s){
		return new Destination(s);
	}
	
	public Contents cont(){
		return new Contents();
	}
	
	public void ship(String dest){
		Contents c = cont();
		Destination d = to(dest);
		System.out.println(d.readLabel());
	}

	public static void main(String[] args) {
          InnerClass innerClass = new InnerClass();
          innerClass.ship("Broken");
          
          InnerClass innerClass1 = new InnerClass();
          InnerClass.Contents c = innerClass1.cont();
          InnerClass.Destination d =  innerClass1.to("VitaminC");
	}

}
